answer "Disabled HyperCard's 'go Back' menu item."
end InstallMenu
on RemoveMenu
MenuHandler "Delete",Example
MenuHandler "Enable","Go","Back"
end RemoveMenu
on domenu anItem
global ExampleMenu, Disabled
--anItem is the name of the menu item choosen
-- HelpMenu is a list of items in my own help menu
-- Disabled is the list of items that I have disabled
if Disabled contains anItem then
answer "HyperCard menu item "&anItem&" is disabled" with "OK"
exit domenu
else if ExampleMenu contains anItem then
DoExample anItem -- see which item it is and do something
else -- is an enable HyperCard item
pass domenu -- pass it on down the line
exit domenu
end if
end domenu
on DoExample anItem
global checked
if anItem is "Check" then
if checked is not true then
MenuHandler "Mark","Example","Check",check
put true into checked
else
MenuHandler "Mark","Example","Check",none
put false into checked
end if
else if anItem is "Test" then
answer "You have chosen the Test menu item."
end if
end DoExample
-- part 3 (button)
-- low flags: 00
-- high flags: A003
-- rect: left=76 top=298 right=320 bottom=176
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 0
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: Install Menu
----- HyperTalk script -----
on mouseUp
global ExampleMenu
if the short name of me is "Install Menu" then
InstallMenu -- see card script
set the name of me to "Remove Menu"
else
RemoveMenu -- see card script
set the name of me to "Install Menu"
end if
end mouseUp
-- part 5 (field)
-- low flags: 01
-- high flags: 2007
-- rect: left=18 top=32 right=288 bottom=480
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 3
-- text size: 10
-- style flags: 0
-- line height: 13
-- part name: Documentation
-- part 6 (button)
-- low flags: 00
-- high flags: A003
-- rect: left=284 top=298 right=320 bottom=453
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 0
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: Show C Source: part 1
----- HyperTalk script -----
on mouseUp
if the short name of me is "Show C Source: part 1" then
set the visible of card field "source1" to true
set the visible of card field "source2" to false
set the name of me to "Show C Source: part 2"
else if the short name of me is "Show C Source: part 2" then
set the visible of card field "source2" to true
set the visible of card field "source1" to false
set the name of me to "Hide C Source"
else
set the visible of card field "source2" to false
set the visible of card field "source1" to false
set the name of me to "Show C Source: part 1"
end if
end mouseUp
-- part 7 (field)
-- low flags: 81
-- high flags: 0007
-- rect: left=18 top=31 right=289 bottom=492
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 3
-- text size: 10
-- style flags: 0
-- line height: 13
-- part name: source1
-- part 8 (field)
-- low flags: 81
-- high flags: 0007
-- rect: left=18 top=31 right=289 bottom=492
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 3
-- text size: 10
-- style flags: 0
-- line height: 13
-- part name: source2
-- part contents for card part 5
----- text -----
MenuHandler version 1.2d10
Roger Brown
version 1.2d7 note: interface to "show" command has changed. See below.
MenuHandler is an XCMD that gives you the ability to add and manipulate your own menus in a HyperCard stack. You can add and delete whole menus and items from menus. You can set and unset check marks. You can change the names of HyperCard's menus and items in them, but this is not advised because HyperCard handles its own menus in a special way. You can, however, hide HyperCard's menus or disable items in them using some features of this XCMD.
To use this XCMD you will have to install your own DoMenu handler and maintain some special globals. These are explained below.
Note: This version does not support hierarchical menus.
Warning: Does not work with menu patches for large Radius screens.
INVOKING MENUHANDLER
HyperCard Syntax is:
MenuHandler opcode,title,other things according to opcode
it returns: error messages
where the opcodes are:
Add - adds a new menu
parameters are title,item string,before
title is the menu title
items is string containing the menu items and their
states in the normal Mac ToolBox format except
for commas instead of semi-colons to make
hypertalk level processing easier
before is a string that names a menu to insert this
one before (if empty, this menu goes at the
end of the menu bar)
Delete - deletes a menu and its handle
parameter is title
Hide - hides a menu but remembers it for later restoration
parameter is title
Show - restores a hidden menu
parameter is title,beforeMenu (used to be afterMenu)
where after menu can be specified or the default is
after all menus (used to be its original position, but it never worked)
Insert - inserts a menu item
parameters are menu title, item name with format
specifications, after item (number or name)
Remove - removes a menu item
parameters are menu title, item name or number
Enable - enables a menu item
parameters are menu title, item name or number
A number of 0 enables the whole menu
Disable - disables a menu item
parameters are menu title, item name or number
A number of 0 disables the whole menu
Mark - checks an item
parameters are menu title, item name or number
and mark: none,command,check,diamond, or apple
To compile: create a project with this and MacTraps. Build as code